import {axiosFactory} from './factory/axios_factory'
import interceptor from './interceptor'
import {axiosConfigUnLogged} from './factory/axios_configs'

///网络api请求，全局单例
const api = axiosFactory()
interceptor.addApi(api)
interceptor.addTokenToHeader(api)

const apiNew = axiosFactory()
interceptor.addNewApi(apiNew)
interceptor.addTokenToHeader(apiNew)

const apiNewUnLogged = axiosFactory(axiosConfigUnLogged)
interceptor.addNewApi(apiNewUnLogged)

export default {
  postNewUnLogged: (url, data, config) => apiNewUnLogged.post(url, data, config),
  postNew: (url, data, config) => apiNew.post(url, data, config),
  getNew: (url, data, config) => apiNew.get(url, config),
  post: (url, data, config) => api.post(url, data, config),
  get: (url, config) => api.get(url, config),
}

